package com.xx.happychatboot.serve.user.controller;


import com.xx.happychatboot.base.vo.response.ResponseDate;
import com.xx.happychatboot.serve.user.domain.entity.SysUserInfo;
import com.xx.happychatboot.serve.user.service.ISysUserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xiaoXuan
 * @since 2024-12-10
 */
@Controller
@RequestMapping("/sysUserInfo")
public class SysUserInfoController {

    @Autowired
    private ISysUserInfoService sysUserInfoService;

    /**
     * 获取用户信息
     * @param userId
     * @return
     */
    @GetMapping("/getUserInfo/{userId}")
    @ResponseBody
    private ResponseDate getUserInfo(@PathVariable("userId") Long userId) {
        return sysUserInfoService.getUserInfo(userId);
    }

    /**
     * 更新用户信息
     * @param userInfo
     * @return
     */
    @PostMapping("/updateUserInfo")
    @ResponseBody
    public ResponseDate updateUserInfo(@RequestBody SysUserInfo userInfo) {
        return sysUserInfoService.updateUserInfo(userInfo);
    }

    /**
     * 通过用户账号查询用户信息
     * @param userName
     * @return
     */
    @GetMapping("/searchUserByUserName/{userName}")
    @ResponseBody
    private ResponseDate searchUserByUserName(@PathVariable("userName") String userName) {
        return sysUserInfoService.searchUserByUserName(userName);
    }
}

